package com.yc.admin.controller.system;

import com.yc.common.core.domain.AjaxResult;
import com.yc.system.dto.StudentDto;
import com.yc.system.dto.TeacherDto;
import com.yc.system.service.IStudentService;
import com.yc.system.service.ITeacherService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("teacher")
@Api("教师")
public class TeacherController {

    @Autowired
    @Qualifier("TeacherServiceImpl")
    private ITeacherService teacherService;

    @Autowired
    private IStudentService studentService;

    @GetMapping("/all")
    @ApiOperation("获取全部教师相关信息")
    public AjaxResult queryTeacherInfo() {
        AjaxResult ajaxResult = AjaxResult.success();
        List<TeacherDto> teaList = teacherService.selectAll();

        ajaxResult.put("teaList", teaList);
        return ajaxResult;
    }

    @GetMapping("/{teacherId}/students")
    @ApiOperation("获取教师教学学生相关信息")
    public AjaxResult queryTeacherWithStudentInfo(@PathVariable String teacherId) {
        AjaxResult ajaxResult = AjaxResult.success();
        List<StudentDto> dtoList = studentService.selectAllStudentWithTeacherId(teacherId);

        ajaxResult.put("stuList", dtoList);
        return ajaxResult;
    }
}
